#ifndef MARKOV_H
#define MARKOV_H

#include "Demo.h"
#include "RenderTarget.h"
#include "Random.h"
#include "VectorBatch.h"
#include "BitmapFont.h"

using namespace Cvekas;

class Markov : public TimelineSegment
{
public:
	Markov(RendererPtr renderer, VectorBatchPtr vector_batch, SpriteBatchPtr sprite_batch, BitmapFontPtr font);
	~Markov();

	virtual void init(boost::weak_ptr<Demo> owner);
	virtual void close();
	
	virtual void update(float t);
	virtual void render(float t);

private:
	void drawArc(const Vector2& center, float radius, float thickness, float angle, float rotation, float wavyness = 0.0f);
	void drawRays(const Vector2& center, float rotation, uint amount, float t);
	void drawKoch(const Vector2& p1, const Vector2& p2, uint levels, Color c);
	void drawSnowflake(const Vector2& center, float size, float angle, float t);

	RenderTargetPtr offscreen_target1;
	RenderTargetPtr offscreen_target2;
	RenderTargetPtr text_target;

	RendererPtr renderer;
	VectorBatchPtr vector_batch;
	SpriteBatchPtr sprite_batch;
	BitmapFontPtr font;

	EffectPtr vector_batch_effect;
	EffectPtr default_sprite_effect;
	EffectPtr blured_sprite_effect;
	Texture2DPtr pattern1;

	std::string text1;
	std::string text2;
	std::string text3;

	Random prng;
};

typedef boost::shared_ptr<Markov> MarkovPtr;

#endif